import pathway as pw
from typing import Dict, Any, Optional

from application.db.mysql_db.info.ResourceSourceDict import ResourceSourceDict


class ResourceSourceDictSchema(pw.Schema):
    source_id: str
    source_name: Optional[Dict[str, Any]]
    source_main_link: str
    source_description_image: Optional[Dict[str, Any]]
    source_intro: Optional[str]


class ResourceSourceDictRead(pw.io.python.ConnectorSubject):

    def run(self):
        select_list = ResourceSourceDict.select().dicts()
        for doc in select_list:
            self.next(**doc)